<?php
sfsf
session_start();
require("library/config.php");
require("library/functions.php");
require("library/image.class.php");
require("library/paging.class.php");

//connect to database
require("library/database.class.php");
$db = new DATABASE();
if (!$db->connect($config['SQL_HOST'],$config['SQL_USERNAME'],$config['SQL_PASSWORD'],$config['SQL_DATABASE'],true))
	exit('Website under maintenance, please come back in a few minutes!');


	
//rewrite url

$value = preg_split('#/#is',$_GET['url']);
/*$url = preg_split('#-#is',$value['0']);
if(count($url)>2)
$url['1'].='-'.$url['2']; */
//echo $url['0'];
//echo $url['1'];
//echo $value['1'];
//echo $_GET['url'];
//print_r($value);
//smarty 
require('Smarty/Smarty.class.php');
$smarty = new Smarty();
$smarty->template_dir 	= 'templates';
$smarty->compile_dir 	= 'Smarty/templates_c';
$smarty->cache_dir 		= 'Smarty/cache';
$smarty->config_dir 	= 'Smarty/configs';

#################language#####################
if(!$_SESSION['lang']){
	$_SESSION['lang'] = "vi";	
}

/*if($_POST["setLang"]){
	if($_SESSION['lang'] == "vi") $_SESSION['lang'] = "en";
	else $_SESSION['lang'] = "vi";
	echo "OK"; exit;	 
}*/
/*
if($_SESSION['lang']=="vi"){
	include("lang/vi.php");	
}
else{
	include("lang/en.php");	
}
$smarty->assign("lang_text",$lang_text);
$smarty->assign("session_lang",$_SESSION['lang']);
###############################################
if($_SESSION["user_id"]){
	$smarty->assign("user_id",$_SESSION["user_id"]);	
}
else{
	$smarty->assign("user_id",0);		
}
###############################################
*/
$smarty->assign("site_title",$lang['sitetitle']);
$smarty->assign("site",$config['SITE']);
$smarty->assign("lang",$lang);
$smarty->assign("lang1",$_SESSION["lang"]);

/*if($_POST["music"] || $_POST["contact"] || $_POST["goPage"]){
	include("includes/ajax.php");
}*/ 
/*
if($_POST["register"] || $_POST["login"] || $_POST["logout"] || $_POST["lostPass"]){
	include("includes/register.php");
}
*/
switch($value[0]){
	case "tu-van-du-lich":
		include("includes/travel_advice.php");		
		$menu = 3;
		break;
	case "tour-trong-nuoc":
		include("includes/local_tour.php");
		$menu = 2;
		break;
	case "products":
		include("includes/search.php");
		$menu = 3;
		break;	
	case "products_detail":
		include("includes/products_detail.php");
		$menu = 3;
		break;
	case "contact":
		include("includes/contact.php");
		$menu = 5;
		break;				
	default:
		include("includes/index.php");
		$menu = 1;
		break;			
}

$lang= $_SESSION['lang'];
//$_SESSION['lang']="vi"; 
	//include("includes/menu.php");
//include("includes/addtopic.php"); 
	$smarty->assign("content",$main_content);
	$smarty->display("index.html");

?>